package avicit.bdp.dcs.task.dto;

import avicit.bdp.dcs.desensitization.dto.TransformerDto;
import avicit.bdp.dcs.utils.JdbcConstants;

/**
 * @金航数码科技有限责任公司
 * @作者：developer
 * @邮箱：developer@avic-digital.com
 * @创建时间： 2020-08-10 09:29
 * @类说明：
 * @修改记录：
 */
public class ColumnMappingDto {
    private String srcColumnName;
    private String srcColumnType;
    private Integer srcColumnLength;
    private String dstColumnName;
    private String dstColumnType;
    private Integer dstColumnLength;
    private String desensitizationRuleId;
    private String desensitizationPolicyId;
    private String srcColumnPrefix;
    private String unmodifyDstColumnName;
    /**
     * modified by wm，2021-08-02，新增数据脱敏参数，原有脱敏策略相关参数保持不变（desensitizationRuleId/desensitizationPolicyId）
     */
    private TransformerDto transformer;

    public String getSrcColumnName() {
        return srcColumnName;
    }

    public void setSrcColumnName(String srcColumnName) {
        this.srcColumnName = srcColumnName;
    }

    public String getSrcColumnType() {
        return srcColumnType;
    }

    public void setSrcColumnType(String srcColumnType) {
        this.srcColumnType = srcColumnType;
    }

    public String getDstColumnName() {
        return dstColumnName;
    }

    public void setDstColumnName(String dstColumnName) {
        this.dstColumnName = dstColumnName;
    }

    public String getDstColumnType() {
        return dstColumnType;
    }

    public void setDstColumnType(String dstColumnType) {
        this.dstColumnType = dstColumnType;
    }

    public String getDesensitizationRuleId() {
        return desensitizationRuleId;
    }

    public void setDesensitizationRuleId(String desensitizationRuleId) {
        this.desensitizationRuleId = desensitizationRuleId;
    }

    public String getDesensitizationPolicyId() {
        return desensitizationPolicyId;
    }

    public void setDesensitizationPolicyId(String desensitizationPolicyId) {
        this.desensitizationPolicyId = desensitizationPolicyId;
    }

    public String getSrcColumnPrefix() {
        return srcColumnPrefix;
    }

    public void setSrcColumnPrefix(String srcColumnPrefix) {
        this.srcColumnPrefix = srcColumnPrefix;
    }

    public String getUnmodifyDstColumnName() {
        return unmodifyDstColumnName;
    }

    public void setUnmodifyDstColumnName(String unmodifyDstColumnName) {
        this.unmodifyDstColumnName = unmodifyDstColumnName;
    }

    public Integer getSrcColumnLength() {
        return srcColumnLength;
    }

    public void setSrcColumnLength(Integer srcColumnLength) {
        this.srcColumnLength = srcColumnLength;
    }

    public Integer getDstColumnLength() {
        return dstColumnLength;
    }

    public void setDstColumnLength(Integer dstColumnLength) {
        this.dstColumnLength = dstColumnLength;
    }

    public TransformerDto getTransformer() {
        return transformer;
    }

    public void setTransformer(TransformerDto transformer) {
        this.transformer = transformer;
    }

    public ColumnMappingDto() {

    }

    public ColumnMappingDto(Builder builder) {
        this.srcColumnName = builder.srcColumnName;
        this.srcColumnType = builder.srcColumnType;
        this.srcColumnLength = builder.srcColumnLength;
        this.dstColumnName = builder.dstColumnName;
        this.dstColumnType = builder.dstColumnType;
        this.dstColumnLength = builder.dstColumnLength;
        this.desensitizationRuleId = builder.desensitizationRuleId;
        this.desensitizationPolicyId = builder.desensitizationPolicyId;
        this.srcColumnPrefix = builder.srcColumnPrefix;
        this.unmodifyDstColumnName = builder.unmodifyDstColumnName;
        this.transformer = builder.transformer;
    }

    public static Builder builder() {
        return new Builder();
    }

    public static final class Builder{
        private String srcColumnName;
        private String srcColumnType;
        private Integer srcColumnLength;
        private String dstColumnName;
        private String dstColumnType;
        private Integer dstColumnLength;
        private String desensitizationRuleId;
        private String desensitizationPolicyId;
        private String srcColumnPrefix;
        private String unmodifyDstColumnName;
        private TransformerDto transformer;

        public Builder srcColumnName(String srcColumnName) {
            this.srcColumnName = srcColumnName;
            return this;
        }
        public Builder srcColumnType(String srcColumnType) {
            this.srcColumnType = srcColumnType;
            return this;
        }
        public Builder srcColumnLength(Integer srcColumnLength) {
            this.srcColumnLength = srcColumnLength;
            return this;
        }
        public Builder dstColumnName(String dstColumnName, String dataSource) {
            if (JdbcConstants.HIVE.equals(dataSource)) {
                this.dstColumnName = dstColumnName.toLowerCase();
                return this;
            }
            this.dstColumnName = dstColumnName;
            return this;
        }
        public Builder dstColumnLength(Integer dstColumnLength) {
            this.dstColumnLength = dstColumnLength;
            return this;
        }
        public Builder dstColumnType(String dstColumnType) {
            this.dstColumnType = dstColumnType;
            return this;
        }
        public Builder desensitizationRuleId(String desensitizationRuleId) {
            this.desensitizationRuleId = desensitizationRuleId;
            return this;
        }
        public Builder desensitizationPolicyId(String desensitizationPolicyId) {
            this.desensitizationPolicyId = desensitizationPolicyId;
            return this;
        }
        public Builder srcColumnPrefix(String srcColumnPrefix) {
            this.srcColumnPrefix = srcColumnPrefix;
            return this;
        }
        public Builder unmodifyDstColumnName(String unmodifyDstColumnName) {
            this.unmodifyDstColumnName = unmodifyDstColumnName;
            return this;
        }
        public Builder transformer(TransformerDto transformer) {
            this.transformer = transformer;
            return this;
        }
        public ColumnMappingDto build() {
            return new ColumnMappingDto(this);
        }
    }

}
